######################################################################
#Replication file for "The Impact of China's AIIB on the World Bank"
#Authors: Jing Qian, James Vreeland, Jianzhi Zhao
#Codes to replicate Figure F.1 - F.2
######################################################################
rm(list = ls())

#Other packages used
library(panelView)

#Setwd
setwd("C:/Users/qianj/Dropbox (Princeton)/AIIB_WB_Replication")

#Load data
load("data/data_main.RData")

###################################
#Produce Figure F1
###################################
png(filename = "figure/Figure_F1.png",
    height = 800,
    width = 1200)
panelView(hard_project_count_all ~ aiib_founder_2016,
          data = df.main,
          index = c("iso2c", "year"),
          background = "white",
          type = "outcome",
          xlab = "",
          ylab = "New World Bank Infrastructure Projects",
          theme.bw = TRUE) + 
  theme(text = element_text(size = 20),
        axis.text.x = element_text(size = 20),
        plot.title = element_text(size = 20)) +
  scale_x_discrete(limits = seq(1992, 2019, 4))
dev.off()

###################################
#Produce Figure F2
###################################
png(filename = "figure/Figure_F2.png",
    height = 800,
    width = 1200)
panelView(soft_project_count_all ~ aiib_founder_2016,
          data = df.main,
          index = c("iso2c", "year"),
          background = "white",
          type = "outcome",
          xlab = "",
          ylab = "New World Bank Non-Infrastructure Projects",
          theme.bw = TRUE) + 
  theme(text = element_text(size = 20),
        axis.text.x = element_text(size = 20),
        plot.title = element_text(size = 20)) +
  scale_x_discrete(limits = seq(1992, 2019, 4))
dev.off()